<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>奔跑的熊大</title>
  <style>
    body {
      background-color: slategrey;
      height: 860px;
    }

    .mountain {
      position: relative;
      top: 50%;
      /* width: 2000px; */
      height: 500px;
      background: url(images/bg.png) no-repeat center center;

      animation: bg 10s infinite linear;
    }

    .bear {
      position: absolute;
      bottom: 100px;
      width: 200px;
      height: 100px;
      background: url(images/bear.png) repeat-x;

      /* 元素可以添加多个动画 使用逗号隔开即可 */
      animation: bear 0.5s steps(8) infinite, move 5s forwards;
    }

    /* 熊大动画 */ 
    @keyframes bear {
      0% {
        background-position: 0 0;
      }

      100% {
        background-position: -1600px, 0;
      }
    }

    @keyframes move {
      0% {
        left: 0;
      }

      100% {
        left: 50%;
        transform: translate(-50%);
      }
    }

    /* 背景动画 */
    @keyframes bg {
      0% {
        background-position: center center;
      }

      100% {
        /* left: -10%; */
        background-position: -3000px center;
      }
    }
  </style>
</head>

<body>
  <div class="mountain">
    <div class="bear"></div>
  </div>

</body>

</html>